package com.ruoyi.bus.service.impl;

import java.util.List;

import com.ruoyi.bus.domain.WitAppoint;
import com.ruoyi.bus.domain.WitPlan;
import com.ruoyi.bus.domain.WitRoute;
import com.ruoyi.bus.service.IWitAppointService;
import com.ruoyi.bus.service.IWitPlanService;
import com.ruoyi.bus.service.IWitRouteService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bus.mapper.WitBusMapper;
import com.ruoyi.bus.domain.WitBus;
import com.ruoyi.bus.service.IWitBusService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 车辆Service业务层处理
 * 
 * @author caiyanshan
 * @date 2021-04-14
 */
@Service
public class WitBusServiceImpl implements IWitBusService 
{
    @Autowired
    private WitBusMapper witBusMapper;
/*
    @Autowired
    private IWitAppointService witAppointService;
    
    @Autowired
    private IWitRouteService witRouteService;
    
    @Autowired
    private IWitPlanService witPlanService;*/

    /**
     * 查询车辆
     * 
     * @param busId 车辆ID
     * @return 车辆
     */
    @Override
    public WitBus selectWitBusById(Long busId)
    {
        return witBusMapper.selectWitBusById(busId);
    }

    /**
     * 查询车辆列表
     * 
     * @param witBus 车辆
     * @return 车辆
     */
    @Override
    public List<WitBus> selectWitBusList(WitBus witBus)
    {
        return witBusMapper.selectWitBusList(witBus);
    }

    /**
     * 新增车辆
     * 
     * @param witBus 车辆
     * @return 结果
     */
    @Override
    public int insertWitBus(WitBus witBus)
    {
        witBus.setCreateTime(DateUtils.getNowDate());
        return witBusMapper.insertWitBus(witBus);
    }

    /**
     * 修改车辆
     * 
     * @param witBus 车辆
     * @return 结果
     */
    @Override
    public int updateWitBus(WitBus witBus)
    {
        return witBusMapper.updateWitBus(witBus);
    }

    /**
     * 批量删除车辆,车辆删除需连带排班和预约数据都删除
     * 
     * @param busIds 需要删除的车辆ID
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteWitBusByIds(Long[] busIds)
    {
        return witBusMapper.deleteWitBusByIds(busIds);
    }

    /**
     * 删除车辆信息
     * 
     * @param busId 车辆ID
     * @return 结果
     */
    @Override
    public int deleteWitBusById(Long busId)
    {
        return witBusMapper.deleteWitBusById(busId);
    }

    public List<WitBus> selectBusByPlanCount(Long routeId){
        return witBusMapper.selectBusByPlanCount(routeId);
    }
    
    public Integer selectCountBus(){
        return witBusMapper.selectCountBus();
    }
    
    public List<WitBus> listBusByLocationDays(){
        return witBusMapper.listBusByLocationDays(30l);
    }
}
